package gui.mainGUIs;

import entities.User;
import gui.designComponents.TMTLabel;
import gui.designComponents.TMTPanel;

import java.awt.Color;
import java.util.Calendar;
import java.util.ResourceBundle;

import javax.swing.BorderFactory;
import javax.swing.JLabel;

import util.DateFormatting;
import app.Model;
import bundles.BundleLoader;

/**
 * The Footer Panel which shows Date and Logged In User
 * 
 * @author MK
 * 
 */
public class FooterPanel extends TMTPanel {

	private JLabel footerLabel;
	private Model model;

	public FooterPanel(Model model) {
		super();
		this.model = model;
		this.setBorder(BorderFactory.createLineBorder(Color.black));
		this.footerLabel = new TMTLabel();
		this.update();
		add(footerLabel);
	}

	public void update() {

		ResourceBundle resBundle = BundleLoader.getResourceBundle();
		User user = this.model.getLoggedInUser();
		String output = "";

		if (user != null) {
			output += resBundle.getString("loggedInAs") + " "
					+ user.getUsername() + " - ";
		}

		output += DateFormatting.toFormattedStringOnlyDate(Calendar
				.getInstance().getTimeInMillis());

		this.footerLabel.setText(output);
	}
}